package com.anbinh.doctor.fragment.benhnhan;

import android.os.Bundle;
import android.support.v4.app.Fragment;
import android.support.v4.view.ViewPager;
import android.view.LayoutInflater;
import android.view.View;
import android.view.ViewGroup;

import com.anbinh.doctor.R;
import com.anbinh.doctor.fragment.account.ImagePagerAdapter;
import com.nostra13.universalimageloader.core.ImageLoader;
import com.nostra13.universalimageloader.core.ImageLoaderConfiguration;

public class FragmentImagePagerPatients extends Fragment {
	private static FragmentImagePagerPatients fragment = null;
	private View mView;

	public static FragmentImagePagerPatients newInstance(int position) {
		fragment = new FragmentImagePagerPatients();
		Bundle bundle = new Bundle();
		bundle.putInt("position", position);
		fragment.setArguments(bundle);
		return fragment;
	}

	@Override
	public void onActivityCreated(Bundle savedInstanceState) {
		super.onActivityCreated(savedInstanceState);
		ViewPager viewPager = (ViewPager) mView.findViewById(R.id.pager);
		/*PagerAdapter adapter = new PagerAdapter(getChildFragmentManager());
		viewPager.setAdapter(adapter);
		
		viewPager.setCurrentItem(getArguments().getInt("position")-1);
		
		Log.d("position",getArguments().getInt("position")+"");
		*/
		ImageLoader imageLoader = ImageLoader.getInstance();
		imageLoader.init(ImageLoaderConfiguration.createDefault(getActivity()
				.getApplicationContext()));
		
		ImagePagerAdapter adapter = new ImagePagerAdapter(
				getActivity(), imageLoader, getArguments().getInt("position"), FragmentImagesPatients.newInstance().getImagesList());
		viewPager.setAdapter(adapter);
		viewPager.setCurrentItem(getArguments().getInt("position"));
	}

	@Override
	public View onCreateView(LayoutInflater inflater, ViewGroup container,
			Bundle savedInstanceState) {
		mView = inflater.inflate(R.layout.fragment_image_viewpager, null);
		return mView;
	}

	

}
